package com.yjz.designpattern.访问者模式;

// 测试代码
public class VisitorPatternDemo {
    public static void main(String[] args) {
        ShoppingCart cart = new ShoppingCart();

        cart.addItem(new Book(29.99, 1.5));
        cart.addItem(new Fruit(3.99, 2.0));

        Visitor priceVisitor = new PriceVisitor();
        Visitor weightVisitor = new WeightVisitor();

        System.out.println("Calculating prices:");
        cart.accept(priceVisitor);

        System.out.println("\nCalculating weights:");
        cart.accept(weightVisitor);
    }
}